<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    const arr = [{speed: 0}, {speed: 0}, {speed: 0}, {speed: 0}, {speed: 12}, {speed: 0}, {speed: 341}, {speed: 342}, {speed: 0}, {speed: 4321}, {speed: 0}, {speed: 0}, {speed: 0}]

    console.log(arr)

    let start = 0
    let end = arr.length - 1


    for (let i = 0; i < arr.length; i++) {
        if (arr[i].speed !== 0) {
            start = i
            break
        }
    }

    for (let j = arr.length - 1; j >= 0; j--) {
        if (arr[j].speed !== 0) {
            end = j
            break
        }
    }

    console.log(`${start},${end}`)

    console.log(arr.slice(start,end))
</script>
</body>
</html>
